from fastapi import APIRouter, Depends
from schemas.common import RETURN, ListRequest
from typing import  List

import models.admin.system.Admin as AdminModel
import models.admin.system.Sms as SmsModel

from server.Base import BaseServer
from core.Depend import has_permission

router = APIRouter(prefix="/Sms", tags=["短信管理"])
dataLimit = False

# 删除短信
@router.delete("/delete",summary="短信删除")
async def sms_delete(id: int, user: AdminModel.redis_admin = Depends(has_permission("system_admin_sms_del"))):
  await BaseServer(SmsModel.sys_sms).delete(id)
  return RETURN.success("删除成功")

# 批量删除短信
@router.delete("/deleteBatch",summary="短信批量删除")
async def sms_delete_batch(ids: List[int], user: AdminModel.redis_admin = Depends(has_permission("system_admin_sms_batch_del"))):
  await BaseServer(SmsModel.sys_sms).deleteAll(ids)
  return RETURN.success("删除成功")
  
# 查询短信 
@router.post("/list",summary="短信列表")
async def list(request:ListRequest, user: AdminModel.redis_admin = Depends(has_permission("system_admin_sms_list"))):
    result = await BaseServer(SmsModel.sys_sms).list(request)
    return RETURN.success("查询成功",result)
